import {observable, action} from "mobx";
import {getTamperDatas, checkProtectDatas} from "../apis/secondAuth";

export default class SecondAuthStore {
    /**
     * 验证码的值
     */
    authCode = "";

    /**
     * CA认证的key
     * @type
     */
    authKey = "";

    /**
     *
     * 待加密的密文数据
     */
    sourcestr = "";

    /**
     * 是否是数据保护的验证窗口
     */
    isProtectDialog = 0;

    /**
     * 二次认证的类型
     */
    @observable
    secondAuthType = 0;

    /**
     * 契约锁验证时的打开的窗口的地址(地址契约锁提供，调用契约锁的接口获取)
     */
    @observable
    signUrl = "";

    constructor() {
        this.saveAuthCode = this.saveAuthCode.bind(this);
        this.setAuthData = this.setAuthData.bind(this);
    }

    @action("设置验证码的值")
    saveAuthCode(acode) {
        this.authCode = acode;
    }

    @action("设置认证的信息")
    setAuthData(data) {
        /*
        this.authKey = data.authKey || "";
        this.sourcestr = data.sourcestr || "";
        this.secondAuthType = data.secondAuthType || 0;
        this.isProtectDialog = data.isProtectDialog || 0;
        */

        /**
         * 设置authKey,sourcestr,secondAuthType,isProtectDialog,signUrl的值
         */
        Object.assign(this, data);
    }
}